package com.yh.correct.service.impl;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yh.correct.dao.IVoLabourMapper;
import com.yh.correct.model.Page;
import com.yh.correct.model.VoLabour;
import com.yh.correct.service.IVoLabourService;
/**
 * 公益劳动登记服务层实现类
 * 
 * @author 王鹏程 
 * @date 2017.03.22
 * @time 13:49    
 */
@Service
public class VoLabourServiceImpl implements IVoLabourService {

	/**
	 * 日志记录
	 */
	private static Logger logger = LogManager.getLogger(VoLabourServiceImpl.class);
	/**
	 * 注入公益劳动登记数据访问层接口
	 */
	@Autowired
	private IVoLabourMapper voLabourMapper;
	/**
	 * 增加公益劳动登记
	 * 
	 * @param voLabour
	 * @return
	 */
	@Override
	public int addVoLabour(VoLabour voLabour) {
		logger.debug("增加公益劳动登记!");
		return voLabourMapper.addVoLabour(voLabour);
	}

	/**
	 * 修改公益劳动登记
	 * 
	 * @param voLabour
	 * @return
	 */
	@Override
	public int editVoLabour(VoLabour voLabour) {
		logger.debug("修改公益劳动登记!");
		return voLabourMapper.editVoLabour(voLabour);
	}

	/**
	 * 删除公益劳动登记
	 * 
	 * @param voLabour
	 * @return
	 */
	@Override
	public int delVoLabour(VoLabour voLabour) {
		logger.debug("删除公益劳动登记!");
		return voLabourMapper.delVoLabour(voLabour);
	}

	/**
	 * 查询单个公益劳动登记
	 * 
	 * @param voLabour
	 * @return
	 */
	@Override
	public Map<String, Object> getVoLabour(VoLabour voLabour) {
		Map<String, Object> map = voLabourMapper.getVoLabour(voLabour);
		logger.debug("查询单个公益劳动登记!");
		return map;
	}

	/**
	 * 模糊查询公益劳动登记
	 * 
	 * @param condition
	 * @return
	 */
	@Override
	public Page getLikeVoLabours(Map<String, Object> condition) {
		Page page=new Page();
		page.setTotalNum(voLabourMapper.getLikeVoLaboursCount(condition));
		int pageSize = Integer.parseInt(String.valueOf(condition.get("pageSize")));
		page.setPageSize(pageSize);
		int curPageNum = Integer.parseInt(String.valueOf(condition.get("pageNum")));
		page.setCurPageNum(curPageNum);
		page.setTotalPage(page.getTotalNum()/pageSize+(page.getTotalNum()%pageSize==0?0:1));
		page.setResult(voLabourMapper.getLikeVoLabours(condition));
		logger.debug("模糊查询公益劳动登记!");
		return page;
	}
	
	/**
	 * 查询所有公益劳动登记
	 * 
	 * @param condition
	 * @return
	 */
	@Override
	public LinkedList<Map<String, Object>> getAllVoLabours(Map<String, Object> condition) {
		logger.debug("查询所有公益劳动登记!");
		return voLabourMapper.getAllVoLabours(condition);
	}
	/**
	 * 查询所有工作人员
	 * 
	 * @return
	 */
	@Override
	public List<Object> getAllPersonnel() {
		logger.debug("查询所有工作人员!");
		return voLabourMapper.getAllPersonnel();
	}

}
